import { defineStore } from "pinia"
import request from '@/utils/request'
import { apiRes, GoodsInfo } from "@/types/data"

export default defineStore('goods', {
  state: () => ({
    info: {} as GoodsInfo
  }),
  actions: {
    async getGoodsInfo(id: string) {
      const res = await request.get<apiRes<GoodsInfo>>('/goods', {
        params: {
          id
        }
      })
      this.info = res.data.result
    },
    resetGoodsInfo() {
      this.info = {} as GoodsInfo
    }
  }
})